<?php
session_start();
require 'common/Utility.php';
require 'db/configuration.php';
require 'crud/CustomSecurity.class.php';
require 'crud/Category.class.php';
require 'crud/Products.class.php';
require 'crud/Shoplist.class.php';
require 'crud/Users.class.php';
require 'crud/Groups.class.php';
require 'slist/slist.php';
require 'products/products.php';
require 'common/Toodledo.class.php';
include_once("js/ajax/agent.php");
loadDB();
loginCheck();
$agent->init();
$products = new Products(con());
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 
<link rel="stylesheet" type="text/css" href="css/main.css" />
<link rel="stylesheet" type="text/css" href="css/page.css" />
<link rel="stylesheet" type="text/css" href="css/component-product.css" />
<link rel="stylesheet" type="text/css" href="js/jcarousel/lib/jquery.jcarousel.css" />
<link rel="stylesheet" type="text/css" href="js/jcarousel/skins/tango/skin.css" />
<link rel="stylesheet" type="text/css" href="js/fancybox/jquery.fancybox-1.2.5.css" media="screen"/>

<script type="text/javascript" src="js/jquery-1.4.2.min.js"> </script>
<script type="text/javascript" src="js/jquery.ui.core.js"> </script>
<script type="text/javascript" src="js/jquery.easing.1.3.js"> </script>
<script type="text/javascript" src="js/ui.draggable.js"> </script>
<script type="text/javascript" src="js/jcarousel/lib/jquery.jcarousel.js"></script>
<script type="text/javascript" src="js/fancybox/jquery.fancybox-1.2.5.pack.js"></script>
<script type="text/javascript" src="js/categories.js"></script>
<script type="text/javascript" src="js/components.js"> </script>
<script type="text/javascript" src="js/util.js"></script>
<script type="text/javascript" src="js/slist.js"> </script>
<script type="text/javascript" src="js/jedit/jquery.jeditable.mini.js"> </script>
<script type="text/javascript" src="js/quicksand/jquery.quicksand.js"> </script>
<script type="text/javascript" src="js/quicksand/jquery-animate-css-rotate-scale.js"> </script>



<title>РъНъТъ</title>
</head>
<body>

<?php include("common/lenta.php"); ?>

<div id="shlist-container">
	<div id="shopping-list">
		<div id="content_list"></div>
		<div id="navigation_control">
			<p>
				<input id="mail" type="button" value="e-mail" onclick="emailList();"/>
				<?php 
				if ($_SESSION['group_id'] != -1){
					echo '<input id="mail_group" type="button" value="e-mail Group" onclick="emailGroupList();"/>';
				}
				?>
				<input id="add-missing" type="button" value="добави липсващите" onclick="clearList();"/>
				<input id="clear" type="button" value="изчисти" onclick="clearList();"/>
				<input id="toodledo" type="button" value="тодледо" onclick="toodledoSync();"/>
			</p>
		</div>
	</div>
	<div id="shopping-list-overlay"></div>
	<div id="lenta-list"></div>
	<div id="buton-div"><input id="list" type="button" value="shopping list" class="servizna-lenta-item" onclick="showHideShoppingList();"></input></div>
</div>



<div id="main">
	
	<div id="product-view">
	<!-- <div id="logo"></div> -->
	<!-- <div id="logo-text"></div> -->
	<?php include("common/servizna-lenta.php"); ?>
	<script language="javascript" type="text/javascript" defer> 
	setSelected('products');	
	</script>
	
	<div id="container">
	<div id="product-view-container">
		<div id="editnew-container"></div>
		<ul id="editnew">
			<li> 
				<input id="editbutton" type="button" value="редактиране" class="editnew" onclick="setEditMode();"></input>
			</li>
			<li>
				<div id="add">
					<a id="fAddButton" class="thickbox" href="add_product.php?iframe">нов продукт</a>
				</div>
			</li>
			<li class="find">
				<input id="find" type="text" name="find" onkeyup="filterS();" />
			</li>
		</ul>

		<div id="top">
		<?php
				$categories = new Category(con());
				$listCategories = $categories->getAll();
				$selectedCategory = "ВСИЧКИ";
				if (isset($_SESSION['selCompCateg'])){
					$selectedCategory = $_SESSION['selCompCateg'];
				}
				
				echo '<script language="javascript" type="text/javascript" defer> generateCategries_o('.json_encode($listCategories).', '.json_encode($selectedCategory).', '.json_encode("filterQ").');</script>'  
			?>

		</div>
		<div id="middle">
		
			<div class="left"></div>
			<div id="content">
					<div id="jscontainer">
						<div class="component-product-div">
						
						<?php
						echo '<script language="javascript" type="text/javascript" defer> generateComponents('.json_encode(getComponents()).');	</script>';?>
						</div>
					</div>
			</div>
			<!--  <div class="right">
				<div class="scrollbar-top"></div>
				<div class="scrollbar-middle"></div>
				<div class="scrollbar-bottom"></div>
			</div>-->
		</div>
		<div id="bottom">
			<div class="bottomleft">
			</div>
			<div class="bottommiddle">
			</div>
			<div class="bottomright">
			</div>
		</div>
	</div>	
		
	</div>
	</div>
</div>

<script type="text/javascript">
$(document).ready(function(){
	$("#list").click(function(){
		$("#shopping-list").animate({
			  "width": "toggle"
		}, { duration: "medium" });
		$(this).toggleClass("active"); return false;
	});

	$('a#fAddButton').fancybox({
		'hideOnContentClick': false,
		'showCloseButton':true,
		'frameWidth': 358,
		'frameHeight': 202,
		'padding':0
	});

	resizemain();
	initFilters();

	 });

$(window).focus(function(){
	  clearTimeout(t);
	  t = setTimeout('check()', 2000);
});

function check(){
	  agent.call('','isSessionActive','sessionCallback');;
	}

function sessionCallback(result){
	  if (result == 1){
	  } else {
		  setTimeout('delayer()', 1000);
	  }
		  
}
function delayer(){
//	    window.location = "./login.php";
	  window.location.reload(1);
	}

</script>

<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-11565452-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })(); 
</script>
</body>
</html>
